home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / ECURSOR.ASM < prev    next >
Assembly Source File  |  1991-12-10  |  2KB  |  74 lines

  1. .model small
  2.  
  3. .data
  4. extrn    video_seg:word
  5. extrn    insert_mode:byte
  6.  
  7. .code
  8. extrn    mcga:near
  9. public    insert
  10. ;--------------------------------------------------;
  11. ;   This toggles the insert/overstrike modes       ;
  12. ;--------------------------------------------------;
  13. insert    proc    near
  14.     push    di
  15.     mov    di,-1
  16. overstrike_mode:
  17.     push    cx        ; save CX
  18.     push    es
  19.     mov    cx,0507h    ; default color, overstrike cursor
  20.     cmp    byte ptr cs:mcga,90h
  21.     jne    i01
  22.     mov    cx,0607h    ; MCGA
  23. i01:    cmp    word ptr video_seg,0B000h
  24.                 ; monochrome video mode?
  25.     mov    ax,40h
  26.     mov    es,ax        ; ES points to BIOS data area
  27.     mov    al,es:[17h]    ; get keyboard status
  28.     mov    ah,es:[84h]    ; get (rows on screen - 1)
  29.     jne    not_mono
  30.     cmp    ah,29        ; rows on screen
  31.     jge    not_mono
  32.     mov    cx,0C0Dh    ; first scan line = 12, last = 13
  33.     mov    ah,42        ; fake a 43-row mode for direct programming
  34. not_mono:
  35.     and    al,10000000b    ; isolate insert toggle
  36.     mov    insert_mode,al
  37.     jz    not_insert
  38.     or    di,di
  39.     jz    not_insert
  40.     shr    ch,1        ; first scan line
  41. not_insert:
  42.     cmp    ah,42        ; is this 43-row EGA mode?
  43.     jae    direct_cursor    ; if so, need to program cursor directly
  44.     cmp    ch,2
  45.     jne    bc01
  46.     inc    ch
  47. bc01:    mov    ah,1        ; set cursor size int 10h function
  48.     push    bp
  49.     int    10h
  50.     pop    bp
  51.     jmp    short size99
  52.  
  53. direct_cursor:
  54.     mov    dx,es:[63h]
  55.     mov    al,0Ah
  56.     mov    ah,ch        ; AH = first scan line
  57.     cmp    byte ptr cs:mcga,90h
  58.     jne    dc01
  59.     shr    ah,1
  60. dc01:    out    dx,ax
  61.     inc    al
  62.     mov    ah,cl        ; AH = last scan line
  63.     cmp    byte ptr cs:mcga,90h
  64.     jne    dc02
  65.     shr    ah,1
  66. dc02:    out    dx,ax
  67.  
  68. size99:    pop    es
  69.     pop    cx        ; restore CX
  70.     pop    di
  71.     ret
  72. insert    endp
  73.     end
  74.